<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
//use vendor\stefanak\bolt;

class UserController extends Controller
{
    public function store(Request $request)
    {
        $name = $request->input('name');
        $id = $request->input('id');
        echo $id;
        echo $name;die;
    }
    public function list()
    {
        $users = DB::table('users')->get();
        var_dump($users);
        foreach ($users as $k => $v) {
            echo $v->user_name;
        }
    }
    //neo4j
    public function neolist()
    {
        require (base_path() . '/vendor/autoload.php');
        $client = Laudis\Neo4j\ClientBuilder::create()->withDriver('default', 'bolt://neo4j:password@localhost')->build();

        $result = $client->run(<<<'CYPHER'
        MERGE (neo4j:Database {name: $dbName}) - [:HasRating] - (rating:Rating {value: 10})
        RETURN neo4j, rating
        CYPHER, ['dbName' => 'neo4j'])->first();

        $neo4j = $result->get('neo4j');
        $rating = $result->get('rating');

        // Outputs "neo4j is 10 out of 10"
        echo $neo4j->getProperty('name').' is '.$rating->getProperty('value') . ' out of 10!';

    }
}
